package net.groupme.group;

import java.util.ArrayList;
import java.util.List;

import net.groupme.model.Group;
import net.groupme.utils.sql.GroupQueryingUtility;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
 * created on 06.12.2007
 * 
 * This class provides some functionality to show lists of Groups.
 * 
 * @author Mischa Frank, <a href="mailto:code@planetfrank.net">code@planetfrank.net</a>
 * @author last edited by: $Author: nicole $
 * 
 * @version $Revision: 1.5 $ $Date: 2008-07-18 13:14:55 $
 */

public class GroupListsManager {

	/** Logger for this class and subclasses */
	protected final Log logger = LogFactory.getLog(getClass());

	
	public GroupListsManager(){
		super();
	}
	
	/**
	 * Returns the 5 latest Groups in GroupMe!
	 * @return a List of Groups
	 */
	public List<Group> get5LatestGroups(){
		return GroupQueryingUtility.getXLatestGroups(5);
	}
	
	/**
	 * Returns the 20 latest Groups in GroupMe!
	 * @return a List of Groups
	 */
	public List<Group> get20LatestGroups(){
		return GroupQueryingUtility.getXLatestGroups(20);
	}
	
	/**
	 * Returns the 10 latest Groups in GroupMe!
	 * @return a List of Groups
	 */
	public List<Group> get10LatestGroups(){
		return GroupQueryingUtility.getXLatestGroups(10);
	}
	
	/**
	 * Returns the 10 latest Groups in GroupMe! which contain at least 3Tags and 3 Resources
	 * @return a List of Groups
	 */
	public List<Group> getLatestGroupsForStartScreen(){
		List<Group> gruppenListe = GroupQueryingUtility.getXLatestGroups(40);
		List<Group> newList= new ArrayList<Group>();
		int i = 0;
		int j = 40;
		while (i<j & newList.size()<6){
			
			if ((gruppenListe.get(i).getTags().size()>1)& (gruppenListe.get(i).getResources().size()>2)){
				newList.add(gruppenListe.get(i));
			}
			i++;
		}
		return newList;
	}
	
}
